package com.mcptt.config.group.sub;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import org.jdom.Element;
import org.jdom.JDOMException;

import com.cloudptt.api.product.log.Log;
import com.mcptt.config.group.sub.sub.Entry;

public class ListEntry {
	public static final String Name = "list";
	private List<Entry> entryList = null;

	public void parse(Element elem) throws JDOMException
	{
		if(elem == null)
		{
			return;
		}
		entryList = new Vector<Entry>();
		List<Element> list = elem.getChildren();//��ø��ڵ���ӽڵ�  
		for(Element subElem:list) 
		{
			String name = subElem.getName();
			Log.debug(this.getClass(), "name = " + name);
			
			if(name == null
					|| name.length() <= 0)
			{
				return;
			}
			if(name.equals(Entry.Name))
			{
				Entry entry = new Entry();
				entry.parse(subElem);
				entryList.add(entry);
			}
		}  
	}
	public List<Entry> getEntryList()
	{
	    return entryList;
	}
	public String toString()
	{
		StringBuffer strBuf = new StringBuffer("\r\n");
		strBuf.append("<").append(Name).append(">");
		for(Iterator<Entry> itor = entryList.iterator(); itor.hasNext();)
		{
			strBuf.append(itor.next());
		}
		strBuf.append("</").append(Name).append(">");

		return strBuf.toString();
	}
}
